//
//  Model.m
//  A_Project_DLS151129_SQ
//
//  Created by 151129-49宋强 on 16/1/20.
//  Copyright © 2016年 www.lanou3g.com蓝鸥. All rights reserved.
//

#import "Model.h"
#import <objc/runtime.h>
#import <objc/message.h>
@implementation Model

#pragma mark - 归档方法
- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:_title forKey:@"标题"];
    [aCoder encodeObject:_content forKey:@"内容"];
    [aCoder encodeObject:_contentid forKey:@"cid"];
    [aCoder encodeObject:_id forKey:@"mid"];
   // [aCoder encodeObject:[NSString stringWithFormat:@"%ld", _age] forKey:@"随便"];
     
    
}
#pragma mark - 解档方法

- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super init];
    if (self) {
        //按照归档时的key取值
        self.title = [coder decodeObjectForKey:@"标题"];
        self.contentid = [coder decodeObjectForKey:@"cid"];
        self.id = [coder decodeObjectForKey:@"mid"];
        self.content = [coder decodeObjectForKey:@"内容"];
    }
    return self;
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    if ([key isEqualToString:@"userinfo"]) {
        self.uname = value[@"uname"];
        self.icon = value[@"icon"];
        self.uid = value[@"uid"];
    }
    if ([key isEqualToString:@"counterList"]) {
        self.comment = [value[@"comment"] stringValue];
        self.like = [value[@"like"] stringValue];
    }
    if ([key isEqualToString:@"playInfo"]) {
        self.tingid = value[@"tingid"];
    }
    
    
}

@end
